package com.gaga.console.base.utils;

import com.gaga.common.enums.AudioPlayType;
import com.gaga.console.core.entity.BvScriptItem;
import com.gaga.console.core.entity.dto.ConfigDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class MyDecimalUtil {

    public static float getFloatVolume(Integer volumne) {
        return new BigDecimal(volumne).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP).floatValue();
    }

    public static float getFloatSpeed(ConfigDto.AudioPlayBaseSetting audioPlaySetting) {
        Integer speed = audioPlaySetting.getSpeed();
        if (AudioPlayType.random.equals(audioPlaySetting.getType())) {
            speed = ThreadLocalRandom.current().nextInt(audioPlaySetting.getMin() , audioPlaySetting.getMax() + 1);
        }
        return new BigDecimal(speed).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP).floatValue();
    }
}
